﻿using System;
using System.Windows.Forms;
using System.Resources;
using System.Globalization;
using CK.Kernel.Plugin;
using CK.Plugin;
using CK.Kernel.Config;
using CommonServices;

namespace AutoClick
{
    /// <summary>
    /// Editor of AutoClick
    /// </summary>
    [PluginEditor(Id = "{4F8107A1-BE88-4c07-AA8B-2744D6FFC0F0}", PublicName = "AutoClick Editor",
     EditorOf = "{F5A81349-1B82-48f0-AAF8-9E6383316EBB}", EditableObjectTypes = new string[] { "User" }, Version = "1.0.0",
    Categories = new string[] { "Editors" })]
    public class AutoClickEditor : IPluginEditor
    {
        #region Variables
        public IPluginConfigAccessor EditedConfiguration { get; set; }
        public int CommonTimerMultiple
        {
            get
            {
                object o = EditedConfiguration.User["CommonTimerMultiple"];
                return o == null ? 4 : (int)o;
            }
            set { EditedConfiguration.User["CommonTimerMultiple"] = value; }
        }
        public int CommonTimerInterval
        {
            get
            {
                object o = EditedConfiguration.User["CommonTimerInterval"];
                return o == null ? 0 : (int)o;
            }
            set { EditedConfiguration.User["CommonTimerInterval"] = value; }
        }
        public int AreaOfReferenceClickRadius
        {
            get
            {
                object o = EditedConfiguration.User["Radius"];
                return o == null ? 20 : (int)o;
            }
            set { EditedConfiguration.User["Radius"] = value; }
        }

        public bool ShowTypesOfClickMenu
        {
            get
            {
                object o = EditedConfiguration.User["ShowTypesOfClick"];
                return o == null ? false : (bool)o;
            }
            set { EditedConfiguration.User["ShowTypesOfClick"] = value; }
        }
        public bool ShowGauge
        {
            get
            {
                object o = EditedConfiguration.User["ShowGauge"];
                return o == null ? false : (bool)o;
            }
            set {EditedConfiguration.User["ShowGauge"] = value; }
        }
        public bool ShowAreaOfReferenceClick
        {
            get
            {
                object o = EditedConfiguration.User["ShowCircle"];
                return o == null ? false : (bool)o;
            }
            set { EditedConfiguration.User["ShowCircle"] = value; }
        }
        public string Algorithm
        {
            get
            {
                object o = EditedConfiguration.User["Algorithm"];
                return o == null ? "ClickIfPointerIsInRadius" : (string)o;
            }
            set { EditedConfiguration.User["Algorithm"] = value; }
        }
        public string TypeOfClick
        {
            get
            {
                object o = EditedConfiguration.User["DefaultTypeOfClick"];
                return o == null ? "NoClick" : (String)o;
            }
            set { EditedConfiguration.User["DefaultTypeOfClick"] = value; }
        }
        #endregion

        #region Constructor
        /// <summary>
        /// Initialize editor's panel
        /// </summary>
        /// <param name="editableObjectTypes"></param>
        /// <param name="o"></param>
        /// <returns></returns>
        public Panel CreatePanel(string[] editableObjectTypes, object o)
        {

            Panel p = new Panel() { Padding = new Padding(20, 20, 20, 20), AutoSize = true };
            AutoClickUserEditor u = new AutoClickUserEditor(this);

            p.Controls.Add(u);

            return p;
        }
        #endregion

        #region IPlugin Membres
        public bool CanStart(out string lastError)
        {
            throw new NotImplementedException();
        }
        public bool Setup(ISetupInfo info)
        {
            throw new NotImplementedException();
        }
        public void Start()
        {
            throw new NotImplementedException();
        }
        public void Stop()
        {
            throw new NotImplementedException();
        }
        public void Teardown()
        {
            throw new NotImplementedException();
        }
        #endregion
    }
}
